<template>
  <div style="width: 100%">
    <div class="ab_tp_wp m-no-select">
      <div class="ab_tp_title">
        <img draggable="false" src="static/image/word/app_dealt_with.png" />
        <div>我的待办</div>
      </div>
    </div>
    <div class="rawModal" v-show="choiceUser"></div>
    <div class="main">
      <div class="main-left">
        <div class="main-left-head">
          <div class="menu-content menu-content-checked" @click.self="checkedMenu($event, 'all')">
            全部待办
          </div>
          <div class="menu-content" @click.self="checkedMenu($event, 'allNoRead')">
            未完成
            <span class="noreadNum" v-show="allNoReadNum > 0">{{
              allNoReadNum
            }}</span>
          </div>
        </div>
        <div class="main-left-body">
          <div v-for="(item, index) in menutypeList" :key="index">
            <div class="menu-title" @click="showChildren(index)">
              <img :src="item.logo" class="menu-logo" /><span class="menu-span">{{ item.name }}</span>
            </div>
            <div v-show="item.show" v-for="(item1, index) in item.children" :key="index">
              <div @click.self="checkedMenu($event, item1.id)" class="menu-content">
                {{ item1.name }}
                <span class="noreadNum" v-if="item1.noReadNum > 0">{{
                  item1.noReadNum
                }}</span>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="main-right">
        <div id="doc_list" v-show="flag == 0">
          <div class="processed_wrap" style="height: 100vh">
            <div class="processed_head">
              <div class="processed_head_item">
                <el-input class="my_el_select" prefix-icon="el-icon-search" v-model="remindSearch" placeholder="请输入关键字" maxlength="15" clearable @keyup.enter.native="remindSearchFn" @clear="remindSearchFn">
                </el-input>
              </div>
              <div class="processed_head_item " style="flex-grow:1.5">
                <el-input v-model="structure" class="my_el_select" prefix-icon="el-icon-search" placeholder="选择发文单位" maxlength="15" clearable @keyup.enter.native="changeStructure" @clear="changeStructure">
                  <template slot="append">
                    <el-button @click.stop.prevent="getUserDetail()">
                      选择
                    </el-button>
                  </template>
                </el-input>
              </div>
              <div class="processed_head_item processed_head_item_time_doc">
                <div class="processed_head_item_type">创建</div>
                <el-date-picker class="my_el_select my_select_time" v-model="remindOfficialTime" type="daterange" align="right" unlink-panels range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"
                  :picker-options="$store.state.pickerOptions" @change="remindSearchFn">
                </el-date-picker>
              </div>
              <div class="processed_head_item processed_head_item_time_doc">
                <div class="processed_head_item_type">处理</div>
                <el-date-picker class="my_el_select my_select_time" v-model="remindOfficialTimeDispose" type="daterange" align="right" unlink-panels range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"
                  :picker-options="$store.state.pickerOptions" @change="remindSearchFn">
                </el-date-picker>
              </div>
            </div>
            <div class="processed_main" @scroll="rolltoBottom($event)" ref="processedMain">
              <p v-if="!remindOfficialList || remindOfficialList.length == 0" style="text-align: center;">
                无数据
              </p>
              <template v-for="(item, index) in remindOfficialList">
                <div :key="'remind_' + index">
                  <div class="remind">
                    <div class="remind_left" @click.stop.prevent="openOid(item)">
                      <div class="remind_left_m">
                        <img v-if="item.isOfficial" src="static/image/home/contact/thing_document.png" />
                        <img v-else src="static/image/home/contact/thing_date.png" />
                      </div>
                      <div class="remind_left_c">
                        <div class="remind_left_c_f">
                          <div v-if="item.isOfficial && !item.viewerTime" class="flagNoRead"></div>
                          <div v-if="item.isOfficial" class="remind_left_c_f_f">
                            <span>{{ item.sendCompany }}</span>
                            <span>[{{ item.year }}]</span>
                            <span v-if="item.sendDept">{{
                              item.sendDept
                            }}</span>
                            <span>{{ item.issuedNumber }}号</span>
                          </div>
                          <div>
                            {{
                              $utilJs.replaceTosymbol(
                                textMsg($utilJs.toRawStr(item.VALUE))
                              )
                            }}
                          </div>
                        </div>
                        <div class="remind_left_c_t">{{ item.CREATEDATE }}</div>
                      </div>
                    </div>
                    <div class="remind_right">
                      <div class="remind_right_btn" v-if="item.isOfficial">
                        <div v-if="
                            item.state != 1 &&
                            item.isFeedback == 1 &&
                            item.feedBacked
                          ">
                          <div :class="{
                              backSuccess: item.feedBacked != 0,
                              backNoSuccess: item.feedBacked == 0,
                            }">
                            {{ item.feedBacked == 0 ? "需反馈" : "已反馈" }}
                          </div>
                        </div>
                      </div>
                      <div class="remind_right_img" v-else @click.stop.prevent="updateIsDones(item)">
                        <div v-if="item.ISDONE == 0">
                          <img src="static/image/home/contact/checkbox_default.png" />
                          <span class="remind_right_img_span"> 完成 </span>
                        </div>
                        <div v-else>
                          <img src="static/image/home/contact/thing_finish.png" />
                          <span class="remind_right_img_span"> 取消 </span>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </template>
            </div>
          </div>
        </div>
        <IndexMsg v-if="flag == 1" :formMsg="formMsg" ref="indexMsg" :downLoadFileList="downLoadFileList" :remindOfficialList="remindOfficialList" @dbNewChat="dbNewChat" @getOfficial="getOfficial"
          @closeRemindView="closeRemindView" @isUpdateRemindList="isUpdateRemindList" @downloadListAddProcess="downloadListAddProcess" @setOfficialFileSQL="setOfficialFileSQL" @updateOver="updateOver" @goBack="goBack"
          @changeFormMsg="changeFormMsg"></IndexMsg>
        <Detail v-if="flag == 2" :formMsg="formMsg" @updateIsDone="updateIsDone" @delRemind="delRemind" @addRemind="addRemind" @goBack="goBack"></Detail>
      </div>
    </div>
    <div v-if="choiceUser">
      <TreeList @getStructure="getStructure"></TreeList>
    </div>
  </div>
</template>

<script>
import IndexMsg from "../../components/template/official_remind"; // 公文
import Detail from "../../components/template/official_chat"; // 即时通讯待办详情
import TreeList from "../../components/template/structureTree.vue";
import { mapMutations, mapState } from "vuex";
import { Alert } from "iview";
import { getRemind } from "@/api/offdoc.js";
import { assetsList } from "@/api/assetsWorkApp.js";
export default {
  name: "",
  props: {
    formMsgs: {
      type: Object,
      default: null,
    },
    flags: {
      type: Number,
      default: 0,
    },
    downLoadFileList: {
      type: Array,
      default: () => {
        return {};
      },
    },
    officialManageTotal: {
      type: Number,
    },
  },
  data() {
    return {
      structure: "", //筛选的部门
      formMsg: {},
      flag: 0,
      menutypeList: [
        {
          name: "公文",
          logo: "static/image/word/offdoc.png",
          show: false,
          children: [
            {
              id: "f0",
              name: "全部",
            },
            {
              id: "f1",
              name: "未完成",
              noReadNum: 0,
            },
            {
              id: "f2",
              name: "已完成",
            },
          ],
        },
        {
          name: "日程提醒",
          logo: "static/image/word/schedule.png",
          show: false,
          children: [
            {
              id: "r0",
              name: "全部",
            },
            {
              id: "r1",
              name: "未完成",
              noReadNum: 0,
            },
            {
              id: "r2",
              name: "已完成",
            },
          ],
        },
      ],
      remindSearch: "",
      remindOfficialTime: "",
      remindOfficialTimeDispose: "",
      offDocParams: {
        //公文查询参数
        keyword: "",
        startTime: "",
        endTime: "",
        viewStartTime: "",
        viewEndTime: "",
        page: 1,
        limit: 20,
        documentState: "",
      },
      officialTotalPage: 1, //公文总页数
      remindOfficialList: [], //待办公文合集
      dataList: [], //公文list
      intervaleARR: [],
      remindStr: "remind", // 初始化我的待办定时器名称字段
      remindList: [],
      remindParams: {
        //待办查询参数
        userid: "",
        keyword: "",
        startTime: "",
        endTime: "",
        pageNumber: 0,
        pageSize: 20,
        isdone: "",
        startRemindTime: "",
        endRemindTime: "",
        sendingUnit: "",
      },
      remindTotalPage: 1, //日程提醒总页数
      type: 0, // 0:全查 1:查公文 2:查待办
      allNoReadNum: 0,
      noReadOffTotalPage: 1, //未读公文总页数
      isSearchAllOff: true, //是否查询全部公文
      checkedE: "", //选中的e
      checkedType: "all", //选中的type
      choiceUser: false, //是否在选择用户
    };
  },

  components: {
    IndexMsg,
    Detail,
    TreeList,
  },

  computed: {},
  watch: {
    remindOfficialList(newval, olval) {
      let dbInfo = sessionStorage.getItem("dbinfo");
      if (dbInfo) {
        let a = newval.filter((item) => item.oId == dbInfo);
        this.openOid(a[0]);
        sessionStorage.setItem("dbinfo", "");
        this.$Message.destroy();
      }
    },
  },

  beforeMount() {},

  mounted() {
    this.flag = this.flags;
    this.formMsg = this.formMsgs;
    this.getOfficDoc();
    // this.getReminders();
  },
  methods: {
    ...mapMutations(["setTimeoutObj"]),
    // 2022/4/19 zc新增 获取公文检索的部门
    getStructure(info) {
      this.choiceUser = !this.choiceUser;
      if (info.bol) {
        this.userInfo = info.list;
        if (info.list.length > 0) {
          this.structure = info.list[0].name;
        }
      }
      this.type = 1;
      this.remindSearchFn();
    },
    // 根据输入的内容搜索部门（未完成）
    getUserDetail() {
      let arr = [];
      this.choiceUser = !this.choiceUser;
    },
    storeTimeoutObj() {
      this.$refs.indexMsg && this.$refs.indexMsg.storeTimeoutObj(); //zk0510修改,元素存在才调方法
    },
    goNextPage() {
      if (this.type == 0) {
        if (this.offDocParams.page >= this.officialTotalPage) {
          if (this.remindParams.pageNumber >= this.remindTotalPage) {
            return false;
          } else {
            this.remindParams.pageNumber++;
            this.getReminders();
          }
        } else {
          this.offDocParams.page++;
          this.getOfficDoc();
        }
      } else if (this.type == 1) {
        if (this.offDocParams.page >= this.officialTotalPage) {
          return false;
        } else {
          this.offDocParams.page++;
          this.getOfficDoc();
        }
      } else if (this.type == 2) {
        if (this.remindParams.pageNumber >= this.remindTotalPage) {
          return false;
        } else {
          this.remindParams.pageNumber++;
          this.getReminders();
        }
      }
    },
    rolltoBottom(e) {
      //滚动到底部
      if (
        e.srcElement.scrollTop + e.srcElement.clientHeight ==
        e.srcElement.scrollHeight
      ) {
        this.goNextPage();
        e.srcElement.scrollTop =
          e.srcElement.clientHeight + e.srcElement.scrollHeight;
      }
    },
    //修改文本内容发送给后台
    textMsg(myMsg) {
      let regLess = /(\<div\>\<br\>\<\/div\>)*$/g; //去除末尾无意义换行
      myMsg = myMsg.replace(regLess, "");
      let reg = /\<img src=['"]static(.+?)\>/g; //匹配图片
      var imgArr = myMsg.match(reg);
      var regx = /\d+\.gif/g; //匹配gif
      var a = [];
      var sendToAndior = myMsg;
      // if (imgArr) {
      //   for (let i = 0, len = imgArr.length; i < len; i++) {
      //     let sdn = imgArr[i].match(regx);
      //     let ins = parseInt(sdn[0].replace(".gif", "")); //获取图片数字
      //     a.push(ins);
      //   }
      //   for (let i = 0, len = imgArr.length; i < len; i++) {
      //     //找到图片描述
      //     let m = Math.floor(a[i] / 36);
      //     let q = a[i] % 36;
      //     sendToAndior = sendToAndior.replace(
      //       imgArr[i],
      //       "[" + this.expression[m][q] + "]"
      //     );
      //   }
      // }
      //找到非<br>div
      let regAdd = /\<div\>[^\<]*\<\/div\>/g;
      let addArr = Array.from(new Set(sendToAndior.match(regAdd)));
      for (let i in addArr) {
        let arrtest = addArr[i].replace(/-/g, "/-/");
        let regh = new RegExp(arrtest, "gim");
        let regDiv = /\<div\>|\<\/div\>/g;
        let str = addArr[i].replace(regDiv, "");
        sendToAndior = sendToAndior.replace(regh, str);
      }
      return sendToAndior;
    },
    //处理表情
    toExpression(str) {
      var reg = /\[[\u4e00-\u9fa5]+\]/g;
      var num = [];
      var imageArr = str.match(reg);
      var imageTrue = [];
      var newArr = [].concat.apply([], this.expression);
      if (imageArr) {
        for (let i = 0, len = imageArr.length; i < len; i++) {
          for (let j = 0, lens = newArr.length; j < lens; j++) {
            if (new RegExp(newArr[j]).test(imageArr[i])) {
              num.push(this.$utilJs.createFaceImage(j));
              imageTrue.push(imageArr[i]);
              break;
            }
          }
        }
        for (let i in imageTrue) {
          str = str.replace(imageTrue[i], num[i]);
        }
      }
      return str;
    },
    checkedMenu(e, type, isBack = 0) {
      //菜单点击事件
      this.checkedE = e;
      this.checkedType = type;
      if (!isBack) {
        //是否需要返回列表页面
        this.flag = 0;
        $(".menu-content").prop("class", "menu-content");
        $(e.target).prop("class", "menu-content menu-content-checked");
      }
      this.remindOfficialList = [];
      this.remindParams.pageNumber = 0;
      this.$refs.processedMain.scrollTop = 0;
      switch (type) {
        case "all":
          this.changeType(0, "");
          break;
        case "allNoRead":
          if (this.structure != "") {
            this.changeType(1, 0);
            break;
          } else {
            this.changeType(0, 0);
            break;
          }
        case "r0":
          this.changeType(2, "");
          break;
        case "r1":
          this.changeType(2, 0);
          break;
        case "r2":
          this.changeType(2, 1);
          break;
        case "f0":
          this.changeType(1, "");
          break;
        case "f1":
          this.changeType(1, 0);
          break;
        case "f2":
          this.changeType(1, 1);
          break;
      }
    },
    changeType(type1, type2 = "") {
      //type1区分待办公文  type已完成未完成
      if (type2.length == 0) {
        this.isSearchAllOff = true;
      } else {
        this.isSearchAllOff = false;
      }
      this.type = type1;
      if (type1 == 2) {
        this.remindParams.pageNumber = 1;
        this.remindParams.isdone = type2;
        this.getReminders();
      }
      if (type1 == 0) {
        this.remindParams.pageNumber = 0;
        this.offDocParams.page = 1;
        this.offDocParams.documentState = type2;
        this.remindParams.isdone = type2;
        this.getOfficDoc();
      }
      if (type1 == 1) {
        this.offDocParams.page = 1;
        this.offDocParams.documentState = type2;
        this.getOfficDoc();
      }
    },
    showChildren(index) {
      //点击显示隐藏子菜单
      this.menutypeList[index].show = !this.menutypeList[index].show;
    },
    changeStructure() {
      if (this.structure == "") {
        this.type = 0;
      } else {
        this.type = 1;
      }
      this.remindOfficialList = [];
      this.$refs.processedMain.scrollTop = 0;
      this.offDocParams.page = 1;
      this.getOfficDoc();
    },
    // 我的待办搜索
    remindSearchFn() {
      console.log("现在的状态", this.type);
      this.remindOfficialList = [];
      this.$refs.processedMain.scrollTop = 0;
      if (this.isSearchAllOff) {
        this.offDocParams.documentState = "";
      }
      if (this.type == 0) {
        this.offDocParams.page = 1;
        this.remindParams.pageNumber = 0;
        this.getOfficDoc();
      } else if (this.type == 1) {
        this.offDocParams.page = 1;
        this.getOfficDoc();
      } else if (this.type == 2) {
        this.remindParams.pageNumber = 1;
        this.getReminders();
      }
      // 2022/6/13 搜索完自动失去焦点避免二次搜索
      event.target.blur();
    },
    //获取公文
    getOfficDoc() {
      this.$startLoading("#doc_list");
      if (this.isSearchAllOff && this.offDocParams.documentState == "") {
        this.offDocParams.documentState = 0;
      }
      this.offDocParams.keyword = this.remindSearch;
      this.offDocParams.sendingUnit = this.structure;
      this.offDocParams.startTime = this.remindOfficialTime
        ? this.$formatDateTime(new Date(this.remindOfficialTime[0]))
        : "";
      this.offDocParams.endTime = this.remindOfficialTime
        ? this.$formatDateTime(new Date(this.remindOfficialTime[1]))
        : "";
      this.offDocParams.viewStartTime = this.remindOfficialTimeDispose
        ? this.$formatDateTime(new Date(this.remindOfficialTimeDispose[0]))
        : "";
      this.offDocParams.viewEndTime = this.remindOfficialTimeDispose
        ? this.$formatDateTime(new Date(this.remindOfficialTimeDispose[1]))
        : "";
      console.log("请求参数为：", this.offDocParams);
      this.$ajax_official(
        "get",
        "office/document/document/myListPage",
        this.offDocParams,
        (res) => {
          if (res.code == 200) {
            console.log("接口返回的数据", res.data);
            if (!res.data || !res.data.dataList) {
              this.dataList = [];
              this.remindOfficialList = [];
              this.noReadOffTotalPage = 1;
              this.$endLoading();
              return false;
            }
            this.menutypeList[0].children[1].noReadNum = res.data.undoneSum;
            this.noReadOffTotalPage = Math.ceil(
              res.data.total / this.offDocParams.limit
            );
            this.$store.state.officialManageTotal = res.data.undoneSum;
            this.allNoReadNum =
              this.menutypeList[0].children[1].noReadNum +
              this.menutypeList[1].children[1].noReadNum;
            // 2022/6/6 zc新增 更新左侧未完成待办内容
            this.$emit("update:officialManageTotal", this.allNoReadNum);
            this.dataList = res.data.dataList;
            this.officialTotalPage = Math.ceil(
              res.data.total / this.offDocParams.limit
            );
            this.dataList.map((item) => {
              item["isOfficial"] = true; //是否是公文
              item["isRemind"] = false; //是否是待办
              item["isManage"] = true; //公文完成状态
              item["CREATEDATE"] = item.snedTime
                ? item.snedTime
                : item.createTime;
              item["VALUE"] = item.title;
              // 处理展示的公文图片
              if (item.docImgPath) item.docImgPath = item.docImgPath.split(",");
            });
            if (this.isSearchAllOff) {
              if (
                (this.noReadOffTotalPage <= 1 ||
                  res.data.dataList.length == 0) &&
                this.offDocParams.page <= 1 &&
                this.offDocParams.documentState == 0
              ) {
                this.remindOfficialList.push(...this.dataList);
                this.offDocParams.documentState = 1;
                this.offDocParams.page = 1;
                this.$endLoading();
                return this.getOfficDoc();
              } else if (
                this.type == 0 &&
                this.offDocParams.documentState == 1
              ) {
                this.remindOfficialList.push(...this.dataList);
                this.remindParams.pageNumber = 1;
                this.$endLoading();
                return this.getReminders();
              } else {
                this.remindOfficialList.push(...this.dataList);
                if (
                  this.noReadOffTotalPage <= this.offDocParams.page &&
                  this.offDocParams.documentState == 0
                ) {
                  this.offDocParams.documentState = 1;
                  this.offDocParams.page = 1;
                  this.$endLoading();
                  this.getOfficDoc();
                }
              }
              // if(this.officialTotalPage <= 1 && this.type == 0 && this.offDocParams.documentState == 1){
              //   this.remindOfficialList.push(...this.dataList);
              //   this.remindParams.pageNumber = 1;
              //   this.getReminders();
              // }
            } else {
              if (this.offDocParams.page <= 1) {
                this.remindOfficialList = this.dataList;
                if (this.officialTotalPage <= 1 && this.type == 0) {
                  this.remindParams.pageNumber = 1;
                  this.getReminders();
                }
              } else {
                return this.remindOfficialList.push(...this.dataList);
              }
              this.$endLoading();
            }
            this.$endLoading();
          } else if (res.code == 401) {
            this.$getOfficialToken(this.myInfo);
            this.$endLoading();
          } else {
            this.$Message.warning(res.msg);
            this.$endLoading();
          }
        },
        (res) => {
          this.$endLoading();
          this.$Message.warning(res.msg);
        }
      );
    },
    async getAssetsList(data) {
      const res = await assetsList(data);

      console.log(res, 651);
    },
    // 获取资产待办
    getAssets() {
      this.$startLoading("#doc_list");
      if (this.isSearchAllOff && this.offDocParams.documentState == "") {
        this.offDocParams.documentState = 0;
      }
      this.offDocParams.keyword = this.remindSearch;
      this.offDocParams.sendingUnit = this.structure;
      this.offDocParams.startTime = this.remindOfficialTime
        ? this.$formatDateTime(new Date(this.remindOfficialTime[0]))
        : "";
      this.offDocParams.endTime = this.remindOfficialTime
        ? this.$formatDateTime(new Date(this.remindOfficialTime[1]))
        : "";
      this.offDocParams.viewStartTime = this.remindOfficialTimeDispose
        ? this.$formatDateTime(new Date(this.remindOfficialTimeDispose[0]))
        : "";
      this.offDocParams.viewEndTime = this.remindOfficialTimeDispose
        ? this.$formatDateTime(new Date(this.remindOfficialTimeDispose[1]))
        : "";

      let access_token = localStorage.getItem("accessToken");
      this.offDocParams.access_token = access_token;
      console.log("请求参数为：", this.offDocParams);

      this.getAssetsList(this.offDocParams);
      // this.$ajax_official(
      //   "get",
      //   "office/document/document/myListPage",
      //   this.offDocParams,
      //   (res) => {
      //     if (res.code == 200) {
      //       console.log("接口返回的数据", res.data);
      //       if (!res.data || !res.data.dataList) {
      //         this.dataList = [];
      //         this.remindOfficialList = [];
      //         this.noReadOffTotalPage = 1;
      //         this.$endLoading();
      //         return false;
      //       }
      //       this.menutypeList[0].children[1].noReadNum = res.data.undoneSum;
      //       this.noReadOffTotalPage = Math.ceil(
      //         res.data.total / this.offDocParams.limit
      //       );
      //       this.$store.state.officialManageTotal = res.data.undoneSum;
      //       this.allNoReadNum =
      //         this.menutypeList[0].children[1].noReadNum +
      //         this.menutypeList[1].children[1].noReadNum;
      //       // 2022/6/6 zc新增 更新左侧未完成待办内容
      //       this.$emit("update:officialManageTotal", this.allNoReadNum);
      //       this.dataList = res.data.dataList;
      //       this.officialTotalPage = Math.ceil(
      //         res.data.total / this.offDocParams.limit
      //       );
      //       this.dataList.map((item) => {
      //         item["isOfficial"] = true; //是否是公文
      //         item["isRemind"] = false; //是否是待办
      //         item["isManage"] = true; //公文完成状态
      //         item["CREATEDATE"] = item.snedTime
      //           ? item.snedTime
      //           : item.createTime;
      //         item["VALUE"] = item.title;
      //         // 处理展示的公文图片
      //         if (item.docImgPath) item.docImgPath = item.docImgPath.split(",");
      //       });
      //       if (this.isSearchAllOff) {
      //         if (
      //           (this.noReadOffTotalPage <= 1 ||
      //             res.data.dataList.length == 0) &&
      //           this.offDocParams.page <= 1 &&
      //           this.offDocParams.documentState == 0
      //         ) {
      //           this.remindOfficialList.push(...this.dataList);
      //           this.offDocParams.documentState = 1;
      //           this.offDocParams.page = 1;
      //           this.$endLoading();
      //           return this.getOfficDoc();
      //         } else if (
      //           this.type == 0 &&
      //           this.offDocParams.documentState == 1
      //         ) {
      //           this.remindOfficialList.push(...this.dataList);
      //           this.remindParams.pageNumber = 1;
      //           this.$endLoading();
      //           return this.getReminders();
      //         } else {
      //           this.remindOfficialList.push(...this.dataList);
      //           if (
      //             this.noReadOffTotalPage <= this.offDocParams.page &&
      //             this.offDocParams.documentState == 0
      //           ) {
      //             this.offDocParams.documentState = 1;
      //             this.offDocParams.page = 1;
      //             this.$endLoading();
      //             this.getOfficDoc();
      //           }
      //         }
      //         // if(this.officialTotalPage <= 1 && this.type == 0 && this.offDocParams.documentState == 1){
      //         //   this.remindOfficialList.push(...this.dataList);
      //         //   this.remindParams.pageNumber = 1;
      //         //   this.getReminders();
      //         // }
      //       } else {
      //         if (this.offDocParams.page <= 1) {
      //           this.remindOfficialList = this.dataList;
      //           if (this.officialTotalPage <= 1 && this.type == 0) {
      //             this.remindParams.pageNumber = 1;
      //             this.getReminders();
      //           }
      //         } else {
      //           return this.remindOfficialList.push(...this.dataList);
      //         }
      //         this.$endLoading();
      //       }
      //       this.$endLoading();
      //     } else if (res.code == 401) {
      //       this.$getOfficialToken(this.myInfo);
      //       this.$endLoading();
      //     } else {
      //       this.$Message.warning(res.msg);
      //       this.$endLoading();
      //     }
      //   },
      //   (res) => {
      //     this.$endLoading();
      //     this.$Message.warning(res.msg);
      //   }
      // );
    },
    //获取日程提醒
    getReminders() {
      this.remindParams.userid = this.$store.state.myInfo.id;
      this.remindParams.keyword = this.remindSearch;
      this.remindParams.startTime = this.remindOfficialTime
        ? this.$formatDateTime(new Date(this.remindOfficialTime[0]))
        : "";
      this.remindParams.endTime = this.remindOfficialTime
        ? this.$formatDateTime(new Date(this.remindOfficialTime[1]))
        : "";
      // 2022/5/6 zc修改 处理时间的起始时间与结束时间
      this.remindParams.startRemindTime = this.remindOfficialTimeDispose
        ? this.$formatDateTime(new Date(this.remindOfficialTimeDispose[0]))
        : "";
      this.remindParams.endRemindTime = this.remindOfficialTimeDispose
        ? this.$formatDateTime(new Date(this.remindOfficialTimeDispose[1]))
        : "";
      getRemind(this.remindParams)
        .then((res) => {
          if (res.result == 200) {
            let remind = res.data || [];
            console.log(this.remindParams, "获取待办参数");
            console.log(res.data, "返回数据");
            this.menutypeList[1].children[1].noReadNum = res.nodones;
            for (let i = 0; i < remind.length; i++) {
              remind[i].VALUE = this.toExpression(
                this.$utilJs.regUrl(remind[i].VALUE || "")
              );
            }
            this.allNoReadNum =
              this.menutypeList[0].children[1].noReadNum +
              this.menutypeList[1].children[1].noReadNum;
            this.remindList = remind || [];
            this.remindList.map((item) => {
              item["isOfficial"] = false;
              item["isRemind"] = true;
            });
            this.remindTotalPage = Math.ceil(
              res.totals / this.remindParams.pageSize
            );
            if (this.remindParams.pageNumber <= 1 && this.type == 2) {
              this.remindOfficialList = this.remindList;
            } else {
              this.remindOfficialList.push(...this.remindList);
            }
          } else {
            this.$Message.warning("查询待办列表失败,请稍后再试");
          }
        })
        .catch((err) => {
          this.$Message.warning("查询待办列表失败,请稍后再试");
        });
    },
    // 点击公文列表
    openOid(item) {
      if (item.isOfficial) this.flag = 1;
      else this.flag = 2;
      //公文的点击事件
      //zk0429新增,切换时停止计时并保存
      window.lookOfficialTimeout && clearTimeout(window.lookOfficialTimeout);
      window.lookOfficialInterval && clearInterval(window.lookOfficialInterval);
      if (this.$refs.indexMsg) {
        console.log(this.$refs.indexMsg.officialTime);
        if (this.$refs.indexMsg.officialTime >= 0 && this.formMsg != null) {
          console.log("进了倒计时设置");
          this.setTimeoutObj({
            id: this.formMsg.oId,
            time: this.$refs.indexMsg.officialTime,
          });
          console.log(this.timeoutObj);
        }
      }
      // 强制刷新组件
      this.formMsg = item;
      console.log(this.formMsg, "点击的item");
    },
    // 公文附件存储本地数据库
    setOfficialFileSQL(arr) {
      this.$emit("setOfficialFileSQL", arr);
    },
    // 公文附件下载
    downloadListAddProcess(item) {
      this.$emit("downloadListAddProcess", item);
    },
    // 跳转至聊天页面
    dbNewChat(info) {
      this.$emit("dbNewChat", info);
    },
    getOfficial() {},
    // 提交反馈后触发
    closeRemindView() {
      this.$emit("closeRemindView");
    },
    // 刷新待办列表
    isUpdateRemindList() {
      this.getOfficDoc();
    },
    // 及时更新完成状态
    updateOver(info) {
      console.log(info, "及时更新完成状态H");
      // this.checkedMenu(this.checkedE, this.checkedType,1)
    },
    // 更新完成状态
    updateIsDone() {
      this.$emit("updateIsDone", this.formMsg);
    },
    updateIsDones(item) {
      item.ISDONE == 0
        ? this.menutypeList[1].children[1].noReadNum--
        : this.menutypeList[1].children[1].noReadNum++;
      this.$emit("updateIsDone", item);
    },
    // 删除待办
    delRemind() {
      this.$emit("delRemind", this.formMsg);
    },
    // 添加待办
    addRemind() {
      this.$emit("addRemind", {
        state: 1,
        item: this.formMsg,
      });
    },
    goBack(val) {
      this.flag = 0;
      this.checkedMenu(this.checkedE, this.checkedType, 1);
    },
    changeFormMsg(index) {
      this.formMsg = this.remindOfficialList[index];
      if (index == this.remindOfficialList.length - 2) {
        this.goNextPage();
      }
    },
  },
};
</script>
<style lang='less' scoped>
.main {
  display: flex;
  text-align: left;
  .main-left {
    background-color: white;
    width: 160px;
    font-size: 14px;
    height: 100vh;
    border-right: 1px solid #e5e5e5;
    color: black;
    .main-left-head {
      padding: 10px 0;
      height: 103px;
      border-bottom: 1px solid #e5e5e5;
      display: flex;
      flex-direction: column;
      justify-content: space-around;
    }
    .main-left-body {
      .menu-title {
        padding: 10px;
        height: 40px;
        line-height: 40px;
        margin-bottom: 10px;
        .menu-logo {
          position: relative;
          top: 5px;
          margin-right: 10px;
        }
      }
    }
    .menu-content {
      height: 32px;
      line-height: 32px;
      padding-left: 40px;
      width: 100%;
      cursor: pointer;
    }
    .menu-content-checked {
      background: #f5f5f5;
      border-right: 4px solid #fa7500;
      color: #fa7500;
    }
  }
  .main-right {
    width: calc(100% - 160px);
    #doc_list {
      position: relative;
    }
    .my_select_time {
      flex: 1;
      min-width: 160px;
      max-width: 210px;
      padding: 0 2px 0 8px;
      height: 32px;
      /deep/.el-range-separator {
        width: 7%;
        padding: 0;
      }
    }
  }
}
/deep/.el-input__inner {
  background-color: #f2f2f2;
  border: none;
  height: 30px;
  border: 1px solid #dcdfe6;
  width: 100px;
  border-radius: 0;
  .el-range-input {
    background-color: #f2f2f2;
    line-height: 30px;
    width: 56%;
    font-size: 12px;
  }
}
.processed_head {
  background-color: #fff;
}
.processed_main {
  height: 100vh !important;
  padding-bottom: 80px !important;
}
.remind_right_img_span {
  position: relative;
  bottom: 3px;
}
.noreadNum {
  padding: 1px 5px;
  background-color: red;
  border-radius: 60%;
  color: #fff;
  font-size: 12px;
}
#doc_list /deep/ .el-input-group__append {
  padding: 0 10px;
}
#doc_list /deep/ .el-input--suffix .el-input__inner {
  padding-right: 5px;
}
</style>
